package it.kion.util.ui.umenumanager2.model;

import java.util.ArrayList;
import java.util.Collection;

public class Folder extends MenuItem {

	Collection<MenuItem> children = null;

	public Folder(String label, Folder parent) {
		super(label, parent, Type.FOLDER);
		children = new ArrayList<MenuItem>();
	}

	public Folder(String label) {
		super(label, Type.FOLDER);
		children = new ArrayList<MenuItem>();
	}

	public Collection<MenuItem> getChildren() {
		return children;
	}

	public void setChildren(Collection<MenuItem> children) {
		this.children = children;
	}

	public Collection<Folder> getChildOfTypeFolder() {
		Collection<Folder> res = new ArrayList<Folder>();
		for (MenuItem item : children) {
			if (item instanceof Folder) {
				res.add((Folder) item);
			}
		}
		return res;
	}

	public Collection<Item> getChildOfTypeItem() {
		Collection<Item> res = new ArrayList<Item>();
		for (MenuItem item : children) {
			if (item instanceof Item) {
				res.add((Item) item);
			}
		}
		return res;
	}

	public void addChild(MenuItem item){
		children.add(item);
	}

}
